package com.jeeplus.test.jlnu.student.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.test.jlnu.student.domain.entity.StudentInfoApprove;
import com.jeeplus.test.jlnu.student.service.StudentInfoApproveService;
import com.jeeplus.test.tools.resp.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "学生信息审批")
@RestController
@Slf4j
@RequestMapping("/studentApprove")
public class StudentInfoApproveController {

    @Autowired
    private StudentInfoApproveService studentInfoApproveService;

    @ApiOperation("查询审批状态")
    @GetMapping("/getOutside")
    public R getOutside(@RequestParam String studentId) {
        if(studentId == null || studentId.isEmpty()){
            return R.error("9999","无效参数");
        }
        List<StudentInfoApprove> list =  studentInfoApproveService.getOutside(studentId);
        return R.suc(list);
    }


    @ApiOperation("分页查询")
    @GetMapping("/getOutsidePage")
    public Page<StudentInfoApprove> getOutsidePage(StudentInfoApprove studentInfoApprove, @RequestParam(defaultValue = "1") int pageNum,
                                                       @RequestParam(defaultValue = "10") int pageSize) {
        Page<StudentInfoApprove> page = new Page<>(pageNum, pageSize);
        Page<StudentInfoApprove> pageResult = studentInfoApproveService.getOutsidePage(studentInfoApprove, page);
        return pageResult;
    }

    @ApiOperation("根据状态查询表单")
    @GetMapping("/getByStatus")
    public R getByStatus(StudentInfoApprove studentInfoApprove) {
        List<StudentInfoApprove> list =  studentInfoApproveService.getByStatus(studentInfoApprove.getStudentId(),studentInfoApprove.getApprovalStatus());
        return R.suc(list);
    }

}
